<template>
	<view class="content">

		<image src="../../static/appointment_banner.png" mode="" class="banner_image"></image>
		<form action="" class="appointment_list">
			<view class="property_name all">
				楼盘名称 <input type="text" name="" placeholder="融圣国际" class="property_inputstyle inputstyle"
					v-model="formdata.name">
			</view>
			<view class="appointment_type all">
				预约类型
				<picker class="input" @change="bindPickerChange($event)" :value="index"
					:range="typeArray" range-key="name">
					<view class="appointment_inputstyle" >{{typeArray[selectTypeIndex].name}}</view>
				</picker>
			</view>
			<view class="housetype all">
				户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型
				<input type="text" name="" placeholder="150" class="housetype_inputstyle inputstyle"
					v-model="formdata.model">
			</view>
			<view class="username all">
				姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名
				<input type="text" name="" placeholder="刘芳" class="username_inputstyle inputstyle"
					v-model="formdata.username">
			</view>
			<view class="information all">
				联系方式 <input type="text" name="" placeholder="13546713187" class="information_style inputstyle"
					v-model="formdata.telephone">
			</view>
			<view class="wechat-number all">
				微信号码 <input type="text" name="" placeholder="15987523524" class="wechat_number_inputstyle inputstyle"
					v-model="formdata.wechat">
			</view>
			<view>
				<button class="appointment_button" @click="appointment()">确定预约</button>
			</view>

			<view class="dialog_tip" v-show="tip" @click="tip = false">
				<view class="dialog_image">
					<image src="../../static/images/common/yuyue_ok.png" mode="widthFix"></image>
				</view>
				<view class="dialog_title">恭喜您预约成功</view>
			</view>
			<view class="bg" v-show="tip" @click="tip = false"></view>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				formdata: {
					name: "",
					type: "",
					model: "",
					telephone: "",
					wechat: "",
					username: "",
					user_id: ""
				},
				tip: false,
				typeArray: [],
				selectTypeIndex:0,
				index: 2,
			};
		},
		methods: {
			bindPickerChange(e) {
					console.log(e)
				this.selectTypeIndex = e.detail.value;
				this.formdata.type =this.typeArray[e.detail.value].id  
				console.log(this.typeArray[e.detail.value])
			},
			getarray() {
				var then = this
				this.$http.post("/system/getBaseInfo", {}).then(res => {
					console.log(res.data.data.yuyueList)
					then.typeArray = res.data.data.yuyueList
				})
			},
			appointment() {
				var then = this
				this.$http.post("/reserve/addReserveInfo", this.formdata).then(res => {
					console.log(res)
					if (res.data.code == 200) {
						then.tip = true
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'error'
						});
					}
				})
			}

		},
		onLoad() {
			this.getarray()
		}
	}
</script>

<style>
	.input {
		font-size: 13px;
		padding-left: 12px;
		margin-left: 20px;
		width: 240px;
		height: 24px;
		background: #FFFFFF;
		border: 1px solid rgba(0, 0, 0, 0.10);
		border-radius: 4px;

	}

	.uni-input {
		margin-right: 10rpx;
	}

	.content {
		width: 100vw;
		height: 100vh;
		position: relative;
		overflow: hidden;
	}

	.appointment_list {
		display: flex;
		justify-content: center;
		position: relative;
		height: 315px;
		color: #666666;
	}

	.banner_image {
		width: 100%;
	}

	.all {
		display: flex;
		flex-direction: row;
		height: 24px;
		font-size: 14px;
		font-family: "PingFang SC", "PingFang SC-Medium";
		color: #000;
		line-height: 24px;
		margin-top: 20px;
	}

	.inputstyle {
		font-size: 13px;
		padding-left: 12px;
		margin-left: 20px;
		width: 240px;
		height: 24px;
		background: #FFFFFF;
		border: 1px solid rgba(0, 0, 0, 0.10);
		border-radius: 4px;
	}

	.appointment_button {
		width: 164px;
		margin-top: 20rpx;
		height: 40px;
		line-height: 40px;
		background: #3d9c36;
		color: #fff;
		border-radius:10rpx;
		position: absolute;
		bottom: 0;
		transform: translate(50%);
	}

	.appointment_inputstyle::after {
		content: url('../../static/images/icon/right_icon.png');
		position: absolute;
		width: 18px;
		height: 18px;
		right: 70rpx;
		transform: translateY(15%);
		opacity: .4;
	}

	.housetype_inputstyle::after {
		content: "(㎡)";
		position: absolute;
		right: 70rpx;
		font-weight: bold;
		transform: translateY(-110%);
		opacity: .4;
	}

	.dialog_tip {
		background-color: #fff;
		font-size: 35rpx;
		text-align: center;
		position: absolute;
		border-radius: 20rpx;
		top: 0%;
		left: 30%;
		z-index: 100;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 20px;

	}

	.dialog_image {
		width: 145rpx;
		height: 136rpx;
	}

	.dialog_image image {
		width: 100%;
		height: 100%;
	}

	.dialog_title {
		color: #333;
		margin-top: 12px;
	}

	.bg {
		width: 100vw;
		height: 100vh;
		position: fixed;
		background-color: rgba(0, 0, 0, .5);
		top: 0rpx;
		left: 0rpx;
		z-index: 1;
	}
</style>
